<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全局组件</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <mycomponent>123456789</mycomponent>  
        <mycomponent>123456789</mycomponent>  
    </div>
    <hr>
    <div id="app2">
        <mycomponent>123456789</mycomponent>  
    </div>

    <script>

        Vue.component('mycomponent',{
            template:`<button @click='add'>点我+1  {{count}}</button>`
            ,data(){
                return {
                    count:0
                }
            },methods: {
                add(){
                    this.count++;
                }
            },
              
        });

        var app = new Vue({
            el:'#app'
        });
        var app2 = new Vue({
            el:'#app2'
        });

    </script>
</body>
</html>